package cn.csc.framework.common.util.number;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.RandomUtil;

import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.Date;

public class ObjectNumberUtils {
    /**
     * @Description: 支付下单订单号
     * param prefix 前缀
     */
    public static String getOrder(String prefix) {
        String s = DateUtil.format(LocalDateTime.now(), "yyMMddHHmmssSSS");
        //int s1 = RandomUtil.randomInt(100000, 999999);
        int s1 = (int) (Math.random() * 999999999);
        int s2 = (int) (Math.random() * 9);
        return prefix + s + s1 + s2;
    }

    public static void main(String[] args) {
        System.out.println(getOrder(""));
        System.out.println(txOrder());
    }

    /**
     * @Description: 企业付款订单号
     */
    public static String txOrder() {
        String s = DateUtil.format(LocalDateTime.now(), "yyyyMMddHHmmss");
        s += (char) (Math.random() * 26 + 'a');
        s += (int) (Math.random() * 99);
        s += (char) (Math.random() * 26 + 'A');
        s += (int) (Math.random() * 9);
        s += (char) (Math.random() * 26 + 'a');
        s += (char) (Math.random() * 26 + 'A');
        s += (int) (Math.random() * 9);
        s += (char) (Math.random() * 26 + 'a');
        s += (char) (Math.random() * 26 + 'A');
        return s;
    }
}
